%matplotlib inline
from IPython.display import HTML
from base64 import b64encode
from IPython.display import Image
%matplotlib inline
Strain is calculated using the central difference scheme. For Eyy the vector displacement from the top and bottom is divided by 2x grid spacing
\[E_{yy}=\frac{(V_{y}*(n+1)-Vy(n-1))}{2.g}\] where Vy is the pixel displacement in the y axis and n is the y coordinate of the displacement pixel g is the grid spacing and is equal to:
\[g=\frac{interrogationwindowsize}{(100/(100-overlap))}\]
def vector_data(file_name,window_size,mm_per_pixel):#mm_per_pixel calculated using Image_J
plot_data=[]
Vy_list=loadtxt(file_name)[:,3]
n_list=loadtxt(file_name)[:,1]
for Vy,n in zip(Vy_list,n_list):
g=(window_size*mm_per_pixel)/(100/75)
Eyy_strain=((Vy*(n+1))-(Vy*(n-1)))/(2*g)
plot_data.append(Eyy_strain)
hist(plot_data);
def data(file_name):
plot_data=loadtxt(file_name)[:,100:]
hist(plot_data.flatten());
from io import BytesIO
from IPython.core import display
from PIL import Image
def display_pil_image(im):
'''
Based on the display hookery:
http://nbviewer.ipython.org/gist/deeplook/5162445
'''
b = BytesIO()
im.save(b, format='png')
data = b.getvalue()
ip_img = display.Image(data=data, format='png', embed=True)
return ip_img._repr_png_()
png_formatter = get_ipython().display_formatter.formatters['image/png']
dpi = png_formatter.for_type(Image.Image, display_pil_image)
This uses the equation above. The error seems much larger than that when the histogram is plotted using the Eyy strain map from DaVis straight away
vector_data('C:\\Users\\Luqmaan\\Anaconda\\eyy_strains\\T9E_Tensile_Vec.txt',32,0.003676)
data('C:\\Users\\Luqmaan\\Anaconda\\eyy_strains\\T9E_Tensile_1.txt')
im = Image.open('C:\Export\Tensile_9_shift\B00001.tif')
im
video = open("C:\Export\Tensile_3_eyy_1.mp4", "rb").read()
video_encoded = b64encode(video)
video_tag = '<video controls alt="test" src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
HTML(data=video_tag)